package cn.cream4u.ksks.aaController;

import cn.cream4u.ksks.abService.ClassServ;
import cn.cream4u.ksks.adPojo.ClassPojo;
import cn.cream4u.ksks.adPojo.ClassPojo5;
import cn.cream4u.ksks.adPojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

@RestController
public class ClassController {
    @Autowired
    ClassServ classServ;

    @RequestMapping("x")
    public Result addClass(@RequestBody ClassPojo pojo) {
        classServ.addClass(pojo);
        return Result.success("");
    }

    @RequestMapping("/class/{kk}")
    public Result addClass(@PathVariable Integer[] kk) {
        classServ.deleteClass(kk);
        System.out.println(Arrays.toString(kk));
        return Result.success("");
    }

    @GetMapping("/class")
    public Result selectClass(int page,@RequestParam(defaultValue = "3") int pagesize, String name, String beginTime, String endTime) {
        return Result.success(classServ.selectClass(page, pagesize, name, beginTime, endTime));

    }
    @RequestMapping("/class/list")
    public Result selectClassList() {
        return Result.success(classServ.selectAll());
    }

    @RequestMapping("/emps/job/{job}")
    public Result kkk(@PathVariable Integer job) {
        return Result.success(classServ.selectJob(job));
    }

    @PutMapping("/class")
    public Result updateClass(@RequestBody ClassPojo5 pojo) {
        System.out.println(pojo);
        classServ.change(pojo);
        return Result.success("null");
    }

}
